<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/15/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/15/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/10/04/ARP%E5%8D%8F%E8%AE%AE%E7%90%86%E8%AE%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/10/04/ARP%E5%8D%8F%E8%AE%AE%E7%90%86%E8%AE%BA/" class="post-title-link" itemprop="url">ARP协议理论</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-10-04 14:52:30" itemprop="dateCreated datePublished" datetime="2022-10-04T14:52:30+08:00">2022-10-04</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/10/04/ARP%E5%8D%8F%E8%AE%AE%E7%90%86%E8%AE%BA/" class="post-meta-item leancloud_visitors" data-flag-title="ARP协议理论" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/10/04/ARP%E5%8D%8F%E8%AE%AE%E7%90%86%E8%AE%BA/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/10/04/ARP%E5%8D%8F%E8%AE%AE%E7%90%86%E8%AE%BA/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        地址解析协议（Address Resolution Protocol，ARP）是通过解析 IP 地址得到数据链路层地址的，是一个在网络协议包中极其重要的网络传输协议，它与网卡有着极其密切的关系，在 TCP/IP 分层结构中，把 ARP 划分为网络层，为什么呢，因为在网络层看来，源主机与目标主机是通过 IP 地址进行识别的，而所有的数据传输又依赖网卡底层硬件，即链路层，那么就需要将这些 IP 地址转换为链路层可以识别的东西，在所有的链路中都有着自己的一套寻址机制，如在以太网中使用MAC 地址进行寻址，标识不同的主机，那么就需要有一个协议将 IP 地址转换为 MAC 地址，由此就出现了 ARP 协议，ARP 协议在网络层被应用，它是网络层与链路层连接的重要枢纽。</p>
<p>​        所谓“地址解析”就是主机在发送帧前将目标 IP 地址转换成目标 MAC 地址的过程。ARP 协议的基本功能就是通过目标设备的 IP 地址，查询目标设备的 MAC 地址，以保证通信的顺利进行。</p>
<p><strong>运作流程大致可以理解为：</strong></p>
<ol>
<li><p>如果主机 A 想发送数据给主机 B，主机 A 首先会检查自己的 ARP 缓存表，查看是否有主机 B 的 IP 地址和 MAC 地址的对应关系，如果有，则会将主机 B 的 MAC 地址作为源 MAC 地址封装到数据帧中。如果本地 ARP 缓存中没有对应关系，主机 A 就会向局域网中广播 ARP 请求（包括发送方的 IP 地址、MAC 地址、接收方的 IP 地址），每台主机接收到 ARP 请求后都检查自己的IP 地址是否与 ARP 请求中的接收方 IP 地址相同，若不相同则丢弃 ARP 请求包。</p>
</li>
<li><p>当交换机接受到此数据帧之后，发现此数据帧是广播帧，因此，会将此数据帧从非接收的所有接口发送出去。</p>
</li>
<li><p>当主机 B 接受到此数据帧后，会校对 IP 地址是否是自己的，并将主机 A 的 IP 地址和 MAC 地址的对应关系记录到自己的 ARP 缓存表中，同时会发送一个 ARP 响应，其中包括自己的 MAC地址。</p>
</li>
<li><p>主机 A 在收到这个回应的数据帧之后，在自己的 ARP 缓存表中记录主机 B 的 IP 地址和 MAC地址的对应关系。而此时交换机已经学习到了主机 A 和主机 B 的 MAC 地址了。</p>
</li>
</ol>
<p><strong>以太网数据包</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210041456088.png" style="zoom:67%;">

<p><strong>ARP数据包</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210041505595.png" style="zoom:67%;">

<p>有的博文上的图如下所示，稍微表达的有点不一样，但总体意思是一样的。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210041506989.png" style="zoom:80%;">

<p>​        前面12个字节是MAC地址，接下来是帧类型，其中0806表示是ARP协议帧。接下来，就是ARP数据包部分了，第一个硬件类型字段表示发送方想要知道的硬件接口类型硬件，对于以太网MAC地址，它的值应该为1。协议类型字段表示要映射的协议地址类型，它的值为0x0800时，即表示要映射为IP地址。</p>
<p>​        接下来的两个单字节长度的字段，称为硬件地址长度和协议地址长度，它们分别指出硬件地址和协议地址的长度，长度单位为字节。对于以太网上ARP请求或应答来说，它们的值分别为6和4，代表MAC地址的长度和IP地址的长度。在ARP协议包中留出硬件地址长度字段和协议地址长度字段可以使得ARP协议在任何网络中被使用，而不仅仅只在以太网中。</p>
<p>​        操作字段op指出ARP数据包的类型，它们可以是ARP请求（值为1)、ARP应答（值为2)、RARP请求（值为3)和RARP应答（值为4)，这里我们只关心前两个类型。RARP为逆地址解析协议，这里简单说一下，RARP用于主机启动时获得自己的IP地址。这个过程很简单：主机启动时，广播发送一个RARP请求数据包，数据包中包含了自身的MAC地址，然后等待响应。网络中另一台主机必须设置为监听RARP请求状态，并在收到请求后为该主机分配一个IP地址并返回RARP应答给主机，一旦收到应答，主机就有了IP地址，就可以在后续中使用了。</p>
<p>RARP 是逆地址解析协议，在这里我们就不用过于深入学习，它在网络中基本已经被淘汰，用于主机在启动的时候获得自己的 IP 地址。</p>
<p>​        接下来的四个字段是发送端的以太网MAC地址、发送端的IP地址、目的端的以太网MAC地址和目的端的IP地址。</p>
<p>​        关于PAD填充字节，是因为以太网的帧有最小长度要求，要求最少要有46字节。为了保证这一点，必须在不足的空间插入填充（pad）字节。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/10/02/stm32f4%E7%BD%91%E7%BB%9CDMA%E6%8F%8F%E8%BF%B0%E7%AC%A6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/10/02/stm32f4%E7%BD%91%E7%BB%9CDMA%E6%8F%8F%E8%BF%B0%E7%AC%A6/" class="post-title-link" itemprop="url">stm32f4网络DMA描述符</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-10-02 11:16:27" itemprop="dateCreated datePublished" datetime="2022-10-02T11:16:27+08:00">2022-10-02</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/10/02/stm32f4%E7%BD%91%E7%BB%9CDMA%E6%8F%8F%E8%BF%B0%E7%AC%A6/" class="post-meta-item leancloud_visitors" data-flag-title="stm32f4网络DMA描述符" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/10/02/stm32f4%E7%BD%91%E7%BB%9CDMA%E6%8F%8F%E8%BF%B0%E7%AC%A6/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/10/02/stm32f4%E7%BD%91%E7%BB%9CDMA%E6%8F%8F%E8%BF%B0%E7%AC%A6/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        stm32f4以太网驱动程序中使用DMA描述符管理缓冲区，其连接结构描述如下图：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210021405254.jpg" style="zoom:67%;">

<p>1、一个以太网数据包可以跨越一个或多个DMA描述符</p>
<p>2、一个DMA描述符只能用于一个以太网数据包</p>
<p>3、DMA描述符列表中的最后一个描述符指向第一个，形成链式结构！</p>
<p>​        描述符有分为增强描述符和常规描述符，我们只讲常规描述符！因为我们的网络例程只使用到了常规描述符。常规描述符和增强描述符的结构体成员变量不同。常规描述符只使用了描述符的前4个成员变量。</p>
<p>​        在STM32的参考手册中，我们可以找到发送描述符的定义，如下：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210022049612.png" style="zoom:77%;">

<p>​        一眼看上去好像很复杂，这些是寄存器吗？但是找了一大堆文档，也没有找到它的寄存器地址，因为它根本就不是什么寄存器，而是4个32Bit的内存。对的，你去找发送描述符的硬件结构，是肯定找不到的，因为它完全是纯软件的概念，它的本质就是我们自己用结构体来实现这个描述符，然后将描述符的首地址写入到【ETH_DMATDLAR】寄存器中，STM32就知道这片内存是用来作为发送描述符了。</p>
<p>​        发送描述符的主要作用就是用来记录发送缓冲区的大小，缓冲区的地址，还有这个缓冲区的状态等等，里面有很多信息，这些信息是用来协同CPU和DMA二者之间工作的。</p>
<p>​        <strong>重要的信息有：</strong></p>
<p>​        TDES 0中的OWN位：</p>
<p>​        0：表示CPU占有描述符，CPU可以从DMA中提取数据，但是DMA不能从FIFO中接收数据。</p>
<p>​        1：表示DMA占有描述符，CPU不可以从DMA中提取数据，DMA可以从FIFO中接收数据。</p>
<p>​        DMA在传输完整个帧或者这个缓存里的数据全部读出以后把该位清0’。每个帧的第一个缓存描述符的占有位，必须在后面缓存描述符的占有位全部置’1’以后，才能置”1’。</p>
<p>​        <strong>发送过程：</strong></p>
<p>​        1、当OWN位为0的时候，表示CPU可以将要发送的数据拷贝到描述符中，拷贝完成以后，我们手动将描述符的OWN位设置为1，以此来告诉DMA控制器，我已经拷贝完数据了，你可以从描述符中取出数据进行发送了。</p>
<p>​        2、这时候DMA就会取出描述符中的数据，将数据发送出去，DMA在操作完描述符以后，自动将OWN位设置为0，告诉CPU，我DMA已经发送完数据啦，你可以拷贝下一帧数据到描述符上了。</p>
<p>​        3、这个时候OWN为0了，重复步骤1</p>
<p>​        整个发送的过程就是这样配合的。这样DMA和CPU之间就不会抢占数据了。</p>
<p>​        <strong>DES 0中的位20 TCH：链接的第二个地址(Second address chained)</strong></p>
<p>​        用来表示描述符中的第二个地址是用来保存下一个描述符地址还是第二个缓冲区的地址。</p>
<p>​        该位置1时，表示描述符中的第二个地址是下一个描述符地址，而非第二个缓冲区地址。也就是ST使用的链式结构。</p>
<p>​        ST的以太网驱动程序中用ETH_DMADESCTypeDef定义DMA描述符，代码如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** </span></span><br><span class="line"><span class="comment">  * @brief  ETH DMA Descriptors data structure definition</span></span><br><span class="line"><span class="comment">  */</span> </span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span>  </span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">  __IO <span class="keyword">uint32_t</span>   Status;           <span class="comment">/*!&lt; Status */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   ControlBufferSize;     <span class="comment">/*!&lt; Control and Buffer1, Buffer2 lengths */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   Buffer1Addr;           <span class="comment">/*!&lt; Buffer1 address pointer */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   Buffer2NextDescAddr;   <span class="comment">/*!&lt; Buffer2 or next descriptor address pointer */</span></span><br><span class="line">  </span><br><span class="line">  <span class="comment">/*!&lt; Enhanced ETHERNET DMA PTP Descriptors */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   ExtendedStatus;        <span class="comment">/*!&lt; Extended status for PTP receive descriptor */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   Reserved1;             <span class="comment">/*!&lt; Reserved */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   TimeStampLow;          <span class="comment">/*!&lt; Time Stamp Low value for transmit and receive */</span></span><br><span class="line">  <span class="keyword">uint32_t</span>   TimeStampHigh;         <span class="comment">/*!&lt; Time Stamp High value for transmit and receive */</span></span><br><span class="line">&#125; ETH_DMADescTypeDef;</span><br></pre></td></tr></table></figure>
<p>​        Status用来表示该描述符的状态<br>​        ControlBufferSize表示该描述符缓冲区数据的长度<br>​        Buffer1Addr用来存放该描述符缓冲区的地址，我们要发送的数据，就是放在这个地址开始的内存中<br>​        Buffer2NextDescAddr表示下一个描述符的地址</p>
<p>​        当我们需要发送数据的时候，我们把数据拷贝到发送描述符的缓冲区中（Buffer1Addr），告诉DMA我们拷贝完成了，DMA就会从发送描述符的缓冲区中取数据，将数据通过以太网外设发送到网络中去。</p>
<p>​        同样地，以太网外设接收到了网络中的数据时，DMA自动拷贝数据到接收描述符的缓冲区中（Buffer1Addr），产生中断告诉CPU，有数据来了，我们就可以取出描述符的数据，从而知道接收到了什么。</p>
<p><strong>发送的数据实际上放在哪里？</strong></p>
<p>​        例如，我们要发送一帧512字节的数据，那么我们就需要先建立一个至少大于512字节的数组，将要发送的数据拷贝到这个数组里面，然后设置这个描述符的数据长度是512即可，如下图所示。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210022134961.png" style="zoom:67%;">

<p><strong>要发送的数据长度超出一个描述符能够存放的最大长度怎么办？</strong></p>
<p>​        如果我们发送的一帧数据很大，一个描述符没有办法放下那么多数据，应该怎么办呢？这时候就需要用到链表，将这帧以太网数据分割位若干部分，分别存放在多个描述符里面，描述符之间用链表的形式建立连接。说起来有点抽象，我们举个例子。</p>
<p>​        例如，有4K字节的一帧数据要发送出去，但是每一个描述符的缓冲区大小只有1K，这时候就需要用4个描述符来存储要发送的这一帧数据，请看下图。我们把第一个1K的数据放入描述符中，并且设置它的TEDS0寄存器的FS位为1，表示这个描述符存储了数据帧的第一个分块，把最后1K的数据放入描述符中，设置它的TDES0寄存器的LS位为1，表示这是该帧数据的最后一个分块。这样DMA就能够根据这些信息组合出一条完整的数据帧，进行发送。<br><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210022138569.png" style="zoom:67%;"></p>
<p>​        在ST代码中定义了两个DMA描述符数组，一个用于DMA接收，一个用于DMA发送，如下DMARxDscrTab和DMATxDscrTab：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210022141306.png"></p>
<p>接收和发送描述的大小通过宏ETH_RXBUFNB和ETH_TXBUFNB来定义，默认都为5。</p>
<p>​        我们知道以链接结构太网描述符的Buffer1Addr成员用来存放缓冲区地址，那么数据缓冲区在哪里？这个数据缓冲区也是定义为数组的，如上面的Rx_Buff和Tx_Buff。把他们联系在一起的代码，把描述符和缓冲区联系起来，也就是下面的函数把描述符标构成链式结构。</p>
<p>​        <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210022145284.png"></p>
<p>解析如下（网上别人的截图）:</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202210022146498.webp"></p>
<p><strong>参考链接</strong>：<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_22902757/article/details/104275441">https://blog.csdn.net/qq_22902757/article/details/104275441</a></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/09/25/stm32f407%E8%A3%B8%E6%9C%BA%E7%A7%BB%E6%A4%8Dlwip2.1.3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/09/25/stm32f407%E8%A3%B8%E6%9C%BA%E7%A7%BB%E6%A4%8Dlwip2.1.3/" class="post-title-link" itemprop="url">stm32f407裸机移植lwip2.1.3</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-09-25 21:12:47" itemprop="dateCreated datePublished" datetime="2022-09-25T21:12:47+08:00">2022-09-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/09/25/stm32f407%E8%A3%B8%E6%9C%BA%E7%A7%BB%E6%A4%8Dlwip2.1.3/" class="post-meta-item leancloud_visitors" data-flag-title="stm32f407裸机移植lwip2.1.3" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/09/25/stm32f407%E8%A3%B8%E6%9C%BA%E7%A7%BB%E6%A4%8Dlwip2.1.3/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/09/25/stm32f407%E8%A3%B8%E6%9C%BA%E7%A7%BB%E6%A4%8Dlwip2.1.3/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><strong>1.lwip源码获取</strong></p>
<p>​        <a target="_blank" rel="noopener" href="http://download-mirror.savannah.gnu.org/releases/lwip/%EF%BC%8C%E4%B8%8B%E8%BD%BD%E4%B8%A4%E4%B8%AA%E5%8C%85%EF%BC%9Alwip-2.1.3.zip%EF%BC%88%E6%BA%90%E7%A0%81%E5%8C%85%EF%BC%89%E5%92%8C">http://download-mirror.savannah.gnu.org/releases/lwip/，下载两个包：lwip-2.1.3.zip（源码包）和</a> contrib-2.1.0.zip（contrib 包），contrib包里面装的是移植和应用lwip的一些应用示例。</p>
<p><strong>2.源码添加</strong></p>
<p>​        将lwip源码包中src目录下的文件都加到自己的keil工程里。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251504210.png" style="zoom:67%;">

<p>​        根据这些源码的功能，分组添加到keil工程里。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251510419.png" style="zoom:67%;">

<p>同时工程中添加lwip头文件路径：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251514924.png" style="zoom:67%;">

<p><strong>3.移植头文件</strong></p>
<p>​        lwip需要一些头文件的支持，比如 lwipopts.h、cc.h、pref.h 等。lwipopts.h 就是用于配置 LwIP 的相关参数的，一般来说LwIP 默认会有参数的配置，存放在 opt.h 文件中，如果用户没有在 lwipopts.h 文件进行配置，那么 LwIP 就会使用 opt.h 默认的参数。</p>
<p>​        这些头文件例子可以在contrib包中找到参考，我们在App文件夹下新建目录arch，用来存放这些文件，我们直接从其他工程中拿过来先用。</p>
<p><strong>4.移植源文件</strong></p>
<p>​        移植源文件主要是移植网卡的驱动，ethernetif.c 文件就是存放这些函数的，LwIP 的 contrib 包中就包含这个文件的模板，我们直接拿过来修改即可。LAN8720A网卡的驱动我们也不会写呀，怎么办？可以直接用cubemx来生成。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251528264.png" style="zoom:67%;">

<p>配置PHY地址为0，LAN8720A第10脚悬空时地址就为0。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251532096.png" style="zoom:67%;">

<p> PHY选择userPHY ,A用系统自带的。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251536837.png" style="zoom:67%;">

<p>PHY参数设置由来：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251540381.png" style="zoom:67%;">

<p>其余的一些配置：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251543586.png" style="zoom:67%;">

<p>使能lwIP并开启静态IP模式：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251544433.png" style="zoom:67%;">

<p>然后生成工程即可。</p>
<p><strong>5.从生成的工程中挑选有用代码</strong></p>
<p>​        到stm32f4xx_hal_conf.h文件中将Ethernet peripheral configuration相关的配置以及宏定义拷贝到自己的工程中。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251553970.png" style="zoom:67%;">

<p>​        自己新建一个.c文件，用来存放lan8720a的初始化等驱动。先将cubemx生成的ethernetif.c文件中的代码拷贝一些过来，下图是部分代码。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202209251639226.png" style="zoom:67%;">

<p>然后cubemx生成的ethernetif.c文件中的代码部分直接拷贝到自己的ethernetif.c文件中。</p>
<p><strong>6.应用程序编写</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">netif</span> <span class="title">gnetif</span>;</span></span><br><span class="line"><span class="keyword">ip4_addr_t</span> ipaddr;</span><br><span class="line"><span class="keyword">ip4_addr_t</span> netmask;</span><br><span class="line"><span class="keyword">ip4_addr_t</span> gw;</span><br><span class="line"><span class="keyword">uint8_t</span> IP_ADDRESS[<span class="number">4</span>];</span><br><span class="line"><span class="keyword">uint8_t</span> NETMASK_ADDRESS[<span class="number">4</span>];</span><br><span class="line"><span class="keyword">uint8_t</span> GATEWAY_ADDRESS[<span class="number">4</span>];</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * LwIP initialization function</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">MX_LWIP_Init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="comment">/* IP addresses initialization */</span></span><br><span class="line">  IP_ADDRESS[<span class="number">0</span>] = <span class="number">192</span>;</span><br><span class="line">  IP_ADDRESS[<span class="number">1</span>] = <span class="number">168</span>;</span><br><span class="line">  IP_ADDRESS[<span class="number">2</span>] = <span class="number">1</span>;</span><br><span class="line">  IP_ADDRESS[<span class="number">3</span>] = <span class="number">100</span>;</span><br><span class="line">  NETMASK_ADDRESS[<span class="number">0</span>] = <span class="number">255</span>;</span><br><span class="line">  NETMASK_ADDRESS[<span class="number">1</span>] = <span class="number">255</span>;</span><br><span class="line">  NETMASK_ADDRESS[<span class="number">2</span>] = <span class="number">255</span>;</span><br><span class="line">  NETMASK_ADDRESS[<span class="number">3</span>] = <span class="number">0</span>;</span><br><span class="line">  GATEWAY_ADDRESS[<span class="number">0</span>] = <span class="number">192</span>;</span><br><span class="line">  GATEWAY_ADDRESS[<span class="number">1</span>] = <span class="number">168</span>;</span><br><span class="line">  GATEWAY_ADDRESS[<span class="number">2</span>] = <span class="number">1</span>;</span><br><span class="line">  GATEWAY_ADDRESS[<span class="number">3</span>] = <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* USER CODE BEGIN IP_ADDRESSES */</span></span><br><span class="line"><span class="comment">/* USER CODE END IP_ADDRESSES */</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">/* Initilialize the LwIP stack without RTOS */</span></span><br><span class="line">  lwip_init();</span><br><span class="line"></span><br><span class="line">  <span class="comment">/* IP addresses initialization without DHCP (IPv4) */</span></span><br><span class="line">  IP4_ADDR(&amp;ipaddr, IP_ADDRESS[<span class="number">0</span>], IP_ADDRESS[<span class="number">1</span>], IP_ADDRESS[<span class="number">2</span>], IP_ADDRESS[<span class="number">3</span>]);</span><br><span class="line">  IP4_ADDR(&amp;netmask, NETMASK_ADDRESS[<span class="number">0</span>], NETMASK_ADDRESS[<span class="number">1</span>] , NETMASK_ADDRESS[<span class="number">2</span>], NETMASK_ADDRESS[<span class="number">3</span>]);</span><br><span class="line">  IP4_ADDR(&amp;gw, GATEWAY_ADDRESS[<span class="number">0</span>], GATEWAY_ADDRESS[<span class="number">1</span>], GATEWAY_ADDRESS[<span class="number">2</span>], GATEWAY_ADDRESS[<span class="number">3</span>]);</span><br><span class="line"></span><br><span class="line">  <span class="comment">/* add the network interface (IPv4/IPv6) without RTOS */</span></span><br><span class="line">  netif_add(&amp;gnetif, &amp;ipaddr, &amp;netmask, &amp;gw, <span class="literal">NULL</span>, &amp;ethernetif_init, &amp;ethernet_input);</span><br><span class="line"></span><br><span class="line">  <span class="comment">/* Registers the default network interface */</span></span><br><span class="line">  netif_set_default(&amp;gnetif);</span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> (netif_is_link_up(&amp;gnetif))</span><br><span class="line">  &#123;</span><br><span class="line">    <span class="comment">/* When the netif is fully configured this function must be called */</span></span><br><span class="line">    netif_set_up(&amp;gnetif);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">  &#123;</span><br><span class="line">    <span class="comment">/* When the netif link is down this function must be called */</span></span><br><span class="line">    netif_set_down(&amp;gnetif);</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">/* Set the link callback function, this function is called on change of link status*/</span></span><br><span class="line">  netif_set_link_callback(&amp;gnetif, ethernetif_update_config);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  HAL_Init();</span><br><span class="line">  SystemClock_Config();</span><br><span class="line"></span><br><span class="line">	LED_Init();</span><br><span class="line">	UART_Init();</span><br><span class="line">	MX_LWIP_Init();</span><br><span class="line"> </span><br><span class="line">  <span class="keyword">while</span> (<span class="number">1</span>)</span><br><span class="line">  &#123;</span><br><span class="line">			<span class="comment">/*</span></span><br><span class="line"><span class="comment">			printf(&quot;hello\r\n&quot;);</span></span><br><span class="line"><span class="comment">			LED0_Toggle();</span></span><br><span class="line"><span class="comment">			HAL_Delay(1000);</span></span><br><span class="line"><span class="comment">		  */</span></span><br><span class="line">			ethernetif_input(&amp;gnetif);</span><br><span class="line">		  sys_check_timeouts();</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>代码编译后烧录，电脑端可以ping通开发板，结束！</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/09/20/%E6%9D%B0%E7%90%86MCU%E5%BC%80%E5%8F%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/09/20/%E6%9D%B0%E7%90%86MCU%E5%BC%80%E5%8F%91/" class="post-title-link" itemprop="url">杰理MCU开发</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-09-20 10:19:08" itemprop="dateCreated datePublished" datetime="2022-09-20T10:19:08+08:00">2022-09-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/09/20/%E6%9D%B0%E7%90%86MCU%E5%BC%80%E5%8F%91/" class="post-meta-item leancloud_visitors" data-flag-title="杰理MCU开发" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/09/20/%E6%9D%B0%E7%90%86MCU%E5%BC%80%E5%8F%91/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/09/20/%E6%9D%B0%E7%90%86MCU%E5%BC%80%E5%8F%91/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        代理提供的一些信息：AC6956C ==635N是同一CPU，杰理是同一CPU核，有不同的外设硬件，目前635 cpu核上，6956最强的硬件外设，包括audio+codec，性价比比较好。另外6956C对应的是br23这个，br23 对应 6956  -635 CPU，br25 -对应 6966 CPU，br19 对应 632N。   </p>
<p>​        编译工具链在codeblock里面不显示的一个解决方法是，把下图中那个红线处点击一下。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20220831162950.png" style="zoom:67%;">

<p>​        下载程序的时候，杰理的下载工具要按下那个按键，绿灯由快闪，变为熄灭，才可以烧录。用codeblock编译后会自动进行烧录，因为codeblock里面进行了设置，如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20220831184624.png" style="zoom:67%;">

<p>烧录的时候报key错误，需要添加key，如下图所示：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20220831185207.png"></p>
<p>​        杰理旗下有很多代理商，每家代理商都有一个key文件，此key文件用于加密固件所用。举例：客户原本从代理商A购买芯片并烧录程序，后面想用代理商B的程序烧录到代理商A已经烧录过程序的芯片中，则是不可以烧录成功的，包括bfu升级文件也无法升级成功。</p>
<p><strong>codeblock的一些快捷键：</strong></p>
<p>​         Ctrl+Shift+C注释掉当前行或选中块，Ctrl+Shift+X则解除注释。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/08/14/LAN8720%E7%AE%80%E4%BB%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/08/14/LAN8720%E7%AE%80%E4%BB%8B/" class="post-title-link" itemprop="url">LAN8720简介</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-08-14 20:00:06" itemprop="dateCreated datePublished" datetime="2022-08-14T20:00:06+08:00">2022-08-14</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2022/08/14/LAN8720%E7%AE%80%E4%BB%8B/" class="post-meta-item leancloud_visitors" data-flag-title="LAN8720简介" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/08/14/LAN8720%E7%AE%80%E4%BB%8B/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/08/14/LAN8720%E7%AE%80%E4%BB%8B/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考的博文链接如下：<a target="_blank" rel="noopener" href="https://blog.csdn.net/doyoung1/article/details/124426014">https://blog.csdn.net/doyoung1/article/details/124426014</a></p>
<p><a target="_blank" rel="noopener" href="https://javaforall.cn/151068.html">https://javaforall.cn/151068.html</a></p>
<p><a target="_blank" rel="noopener" href="http://t.zoukankan.com/wllgo-p-10839799.html">http://t.zoukankan.com/wllgo-p-10839799.html</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/u012568663/article/details/120894150">https://blog.csdn.net/u012568663/article/details/120894150</a></p>
<h3 id="1-系统框图"><a href="#1-系统框图" class="headerlink" title="1.系统框图"></a>1.系统框图</h3><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/ff12b910785d417a860e62a3a124e2a0.png"></p>
<pre><code>     LAN8720是一款PHY芯片，寄存器配置与数据传输的接口是相互独立的，寄存器配置接口为SMI，数据传输接口为RMII，SMI接口为一根时钟线，一根数据线，被称做串行管理接口，RMII接口用来传输数据，相比MII接口，更加精简，被称做精简MII接口，其中字母R即reduced。</code></pre>
<h3 id="2-参考电路"><a href="#2-参考电路" class="headerlink" title="2.参考电路"></a>2.参考电路</h3><p>正点原子的电路：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20220812210517.png" style="zoom:80%;">

<p>微雪的电路：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/b6c0128c-e9a2-4a9a-9e20-611d38da5dff2022061919cad5fd-2151-48b9-85d9-f12167ba86d31.jpg"></p>
<p>从原理图中可以看出正点原子的LAN8720A模块所使用的晶振是25M,而微雪的LAN8720A模块使用的晶振是50M,</p>
<p>微雪的LAN8720A的nINTSEL没有接下拉，则是默认使用内部上拉到高电平，即nINTSEL=1，为REF_CLK In Mode模式，所以选用50M的晶振。正点原子的nINTSEL下拉到了GND，为REF_CLK Out Mode模式，所以用25M晶振倍频到50M，可以节省成本。</p>
<h3 id="3-重要引脚"><a href="#3-重要引脚" class="headerlink" title="3.重要引脚"></a>3.重要引脚</h3><h4 id="3-1-RXER-PHYAD0引脚"><a href="#3-1-RXER-PHYAD0引脚" class="headerlink" title="3.1 RXER/PHYAD0引脚"></a>3.1 RXER/PHYAD0引脚</h4><p>​        MAC可以通过SMI接口来读写PHY(LAN8720)的寄存器，SMI最多可以控制32个PHY芯片，通过不同的PHY芯片地址来对不同的PHY操作。LAN8720通过设置RXER/PHYAD0引脚来设置其PHY地址，默认情况下为0，其地址设置如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1639357-20190509170110539-1496476022.png" style="zoom:57%;">

<h4 id="3-2-nINT-REFCLKO引脚"><a href="#3-2-nINT-REFCLKO引脚" class="headerlink" title="3.2 nINT/REFCLKO引脚"></a>3.2 nINT/REFCLKO引脚</h4><p>​        nINTSEL引脚(2号引脚)用于设置nINT/REFCLKO引脚(14号引脚)的功能。nINTSEL配置如下图所示。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1639357-20190509170408708-1747239924.png" style="zoom:67%;">

<p><strong>REF_CLK In模式</strong></p>
<p>​        当工作在REF_CLK In模式时，50MHz的外部时钟信号应接到LAN8720的XTAL1/CKIN引脚(5号引脚)和STM32F407的RMII_REF_CLK(PA1)引脚上，如下图所示。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1639357-20190509170903823-415684001.png"></p>
<p><strong>REF_CLK Out模式</strong></p>
<p>​        为了降低成本，LAN8720可以从外部的25MHz的晶振中产生REF_CLK时钟。到要使用此功能时应工作在REF_CLK Out模式时。当工作在REF_CLO Out模式时REF_CLK的时钟源如下图所示。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/1639357-20190509171426430-1676245566.png"></p>
<h4 id="3-3-MODE-2-0-引脚"><a href="#3-3-MODE-2-0-引脚" class="headerlink" title="3.3  MODE[2:0]引脚"></a>3.3  MODE[2:0]引脚</h4><p>​        用于选择 LAN8720A 网络通信速率和工作模式，可选 10Mbps 或 100Mbps 通信速度，半双工或全双工工作模式。另外 LAN8720A 支持 HP Auto-MDIX 自动翻转功能，即可自动识别直连或交叉网线并自适应。一般将 MODE 引脚都设置为 1，可以让 LAN8720A 启动自适应功能，它会自动寻找最优工作方式。MODE[0]与 RXD0 引脚共用、MODE[1]与 RXD1 引脚共用、MODE[2]与 CRS_DV 引脚共用。</p>
<p>​        通过MODE[2:0] 硬件配置引脚，可以支持以下几种模式： </p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/54560d98453b4d6eb25d80dd62666c0c.jpg" style="zoom:80%;">

<h4 id="3-4-REGOFF引脚"><a href="#3-4-REGOFF引脚" class="headerlink" title="3.4 REGOFF引脚"></a>3.4 REGOFF引脚</h4><p>​        REGOFF引脚用于配置内部+1.2V电压源，LAN8720A 内部需要+1.2V电压，可以通过VDDCR引脚输入+1.2V 电压提供，也可以直接利用 LAN8720A 内部+1.2V 稳压器提供。当REGOFF引脚为低电平时选择内部+1.2V稳压器。REGOFF与 LED1 引脚共用。</p>
<h3 id="4-STM32F4和LAN8720的连接"><a href="#4-STM32F4和LAN8720的连接" class="headerlink" title="4.STM32F4和LAN8720的连接"></a>4.STM32F4和LAN8720的连接</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20220814194117.png" style="zoom:80%;">

<h4 id="4-1-SMI-接口"><a href="#4-1-SMI-接口" class="headerlink" title="4.1 SMI 接口"></a>4.1 SMI 接口</h4><p>​        即站管理接口，该接口允许应用程序通过 2 条线：时钟(MDC)和数据线(MDIO)。访问任意 PHY 寄存器。该接口支持访问多达 32 个 PHY，应用程序可以从 32 个 PHY 中选择一个 PHY，然后从任意 PHY 包含的 32 个寄存器中选择一个寄存器，发送控制数据或接收状态信息。任意给定时间内只能对一个 PHY 中的一个寄存器进行寻址。</p>
<h4 id="4-2-RMII-接口"><a href="#4-2-RMII-接口" class="headerlink" title="4.2 RMII 接口"></a>4.2 RMII 接口</h4><p>​        即精简介质独立接口，该接口降低了在 10/100 Mbit/s 下微控制器以太网外设与外部 PHY 间的引脚数。根据 IEEE 802.3u 标准，MII 包括 16 个数据和控制信号的引脚。RMII 规范将引脚数减少为 7 个。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20220814195332.png" style="zoom:50%;">

<p>​        因为 RMII 相比 MII，其发送和接收都少了两条线。因此要达到 10Mbit/s 的速度，其时钟频率应为 5MHZ，同理要达到100Mbit/s 的速度其时钟频率应为 50MHz，而 MII 接口分别为 2.5MHZ 和 25MHZ。</p>
<h3 id="5-OSI模型"><a href="#5-OSI模型" class="headerlink" title="5. OSI模型"></a>5. OSI模型</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20220814195854.png" style="zoom:67%;">

<p>​        在一般的 LWIP 实验中 PHY 层芯片 LAN8720 相当于物理层，STM32F407 自带的 MAC 层相当于数据链路层,而 LWIP 提供的就是网络层、传输层的功能，应用层是需要用户自己根据自己想要的功能去实现。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/07/27/%E6%B7%B1%E5%85%A5%E8%A7%A3%E6%9E%90stm32f407%E6%80%BB%E7%BA%BF%E6%9E%B6%E6%9E%84(%E8%BD%AC%E8%BD%BD)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/07/27/%E6%B7%B1%E5%85%A5%E8%A7%A3%E6%9E%90stm32f407%E6%80%BB%E7%BA%BF%E6%9E%B6%E6%9E%84(%E8%BD%AC%E8%BD%BD)/" class="post-title-link" itemprop="url">深入解析stm32f407总线架构(转载)</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-07-27 09:24:07" itemprop="dateCreated datePublished" datetime="2022-07-27T09:24:07+08:00">2022-07-27</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/07/27/%E6%B7%B1%E5%85%A5%E8%A7%A3%E6%9E%90stm32f407%E6%80%BB%E7%BA%BF%E6%9E%B6%E6%9E%84(%E8%BD%AC%E8%BD%BD)/" class="post-meta-item leancloud_visitors" data-flag-title="深入解析stm32f407总线架构(转载)" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/07/27/%E6%B7%B1%E5%85%A5%E8%A7%A3%E6%9E%90stm32f407%E6%80%BB%E7%BA%BF%E6%9E%B6%E6%9E%84(%E8%BD%AC%E8%BD%BD)/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/07/27/%E6%B7%B1%E5%85%A5%E8%A7%A3%E6%9E%90stm32f407%E6%80%BB%E7%BA%BF%E6%9E%B6%E6%9E%84(%E8%BD%AC%E8%BD%BD)/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    本文转载于网络，原文链接：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/368923466">https://zhuanlan.zhihu.com/p/368923466</a></p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-c9514067e31ff22f974f83344906309c_720w.jpg"></p>
<p>​        上图是stm32f405\407xx的datasheet中的结构总览图，我们就从这张图作为起点。显然这张图相当复杂，我们还是需要有步骤、有顺序的去分析它。左上角有个大块的正方形示意的模块是整个器件最重要的核心——ARM Cortex-M4内核的CPU，它的主频最高可达168MHz，同时它带有一个FPU（浮点运算单元）。在它的上面有JTAG &amp; SW、ETM、MPU、NVIC四个部件，暂时我们把它们看成一个整体就行了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-32bb42bbe857d086f354f9ad1394c44d_720w.jpg" style="zoom:80%;">

<p>​        从图中可以看到内核的右边有三个端口，分别是D-BUS、I-BUS、S-BUS，这是内核对其他部件进行通讯的总线。三条总线顾名思义就是数据总线、指令总线和系统总线。这三根总线连接到其后一个梯形，这是stm32f4的32位AHB总线矩阵，AHB——先进高性能总线，简单理解就是主要用于内部互联的高速总线。它使用一个轮询算法来进行主节点间仲裁访问：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-3fa8ad4f6247b0a62032a62ebafc3e4c_720w.png" style="zoom:80%;">

<p>​        这是stm32f4的交通枢纽，从图中我们可以看到它的前后插着很多管道。按照结构总览图来分析的话，显然非常的繁杂，我们围绕这个总线矩阵来抽象一下它的周边，并且切实来看一下矩阵内部的连接情况。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-98622a4256cd84b84cadb49e76dbd64d_720w.jpg" style="zoom:100%;">

<p>​        我们把总线矩阵内部简化成横竖相交的排线，矩阵外部就是它所连接的所有部件。左上角可以清晰看到最重要的ARM Cortex-M4内核的CPU，可以看到它的三条总线都连接到了总线矩阵上。在D-bus上还挂着一个64K字节的CCM数据动态存储器，这是一个紧耦合存储器，CPU可以快速的读写CCM内的数据，也只有CPU能够直接访问它。</p>
<p>​        图中上排和侧列显示了总线的主次关系，上排在总线上是主要部件。而侧列则是次要部件。主要部件发起读写，而次要部件往往被动的响应读写。因此可以看到，次要部件往往就是一些存储器和外围的外设总线。总线矩阵为主要部件访问次要部件提供了一种访问机制，即使多个高速外设同时工作，也能实现并发访问和高效操作。我们来看一下主要部件的8根总线：</p>
<ul>
<li>带有CPU的I-bus、D-bus和S-bus三根总线</li>
<li>DMA1内存总线</li>
<li>DMA2内存总线</li>
<li>DMA2外设总线</li>
<li>以太网DMA总线</li>
<li>USB OTG HS DMA总线</li>
</ul>
<p><strong>I-bus</strong>，用于CPU内核进行取指令操作。其访问目标是存储器中——内部Flash内存（通过ICode总线）、SRAM或通过FSMC扩展的内存——包含的代码</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-cf4e0207d05734988679ef31eda9e518_720w.jpg"></p>
<p><strong>D-bus</strong>，用于CPU内核进行数据加载和调试访问，并且还顺便连接了CCM数据存储器。其访问目标是存储器中——内部Flash内存（通过DCode总线）、SRAM或通过FSMC扩展的内存——包含的代码和数据</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-b30b30d53333e2ccc49c5c404db10858_720w.jpg"></p>
<p><strong>S-bus</strong>，用于CPU内核进行访问位于外设或SRAM中数据。也可从这条总线获取指令，但是效率比ICode（I-bus）要低。其访问目标是内部的SRAM1、SRAM2，AHB1外设包含APB外设，AHB2外设和通过FSMC扩展的内存。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-a1f644ff661968912f4f6f603fcd1700_720w.jpg"></p>
<p><strong>DMA内存总线</strong>，此总线连接DMA内存总线主接口到总线矩阵。用于DMA执行到内存的传输。其访问目标是数据内存——内部的SRAM(SRAM1，SRAM2) 和通过FSMC扩展的内存。（注：图中可见，DMA2内存访问的范围比DMA1还要广）</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-26c7b1e25749268c998cfc9fafab583a_720w.jpg"></p>
<p><strong>DMA外设总线</strong>，此总线用于DMA访问AHB外设或内存之间的传输。其访问目标是AHB和APB外设加数据内存——内部SRAM(SRAM1，SRAM2)和通过FSMC扩展的内存。（注：图中可见，DMA2外设访问的范围比DMA1要广，而且两者目标不相同）</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-0667df9a4030b92e5ef9604c6550a4c7_720w.jpg"></p>
<p><strong>以太网DMA总线</strong>，此总线用于以太网DMA载入/存储数据到内存。其目标是数据内存——内部SRAMs (SRAM1, SRAM2)、内部Flash存储器和通过FSMC扩展的内存。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-bcd25f7fa6bc5fe37238b6c33d09022f_720w.jpg"></p>
<p><strong>USB OTG HS DMA总线</strong>，此总线用于USB OTG HS DMA载入/存储数据到内存。其目标是数据内存——内部SRAMs (SRAM1, SRAM2)、内部Flash存储器和通过FSMC扩展的内存。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/v2-44145a1941e04924dedf9d223e8b1e6c_720w.jpg"></p>
<p>综上，可以看到主要部件总线通过总线矩阵与次要部件总线连接，对应于次要部件的7根总线有：</p>
<ul>
<li>内部Flash存储器ICode总线</li>
<li>内部Flash存储器DCode总线</li>
<li>主内部SRAM1 (112 KB)</li>
<li>辅内部SRAM2 (16 KB)</li>
<li>AHB1外设，包括AHB/APB桥和 APB外设</li>
<li>AHB2外设</li>
<li>FSMC</li>
</ul>
<p>​        我们再来讨论一下其中的AHB/APB桥接。APB总线又称为先进外设总线。顾名思义它连接了大部分外设。而APB是通过AHB/APB桥连接到AHB总线上的。系统中有两路APB到AHB的桥，并提供了独立的异步访问，因此可以独立设置外设的频率。这里也需要注意的是，当设备重启，除SRAM和内部Flash接口外，所有的外设时钟被关闭了。因此启动后需要重新初始化相应的时钟。当对APB的寄存器进行一次8、16位访问的时候，所有数据将会扩展为一个32位副本。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/07/17/STM32%20IAP%E8%B7%B3%E8%BD%ACAPP%E6%97%B6%E6%AD%BB%E6%9C%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/07/17/STM32%20IAP%E8%B7%B3%E8%BD%ACAPP%E6%97%B6%E6%AD%BB%E6%9C%BA/" class="post-title-link" itemprop="url">STM32 IAP跳转APP时死机</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-07-17 21:27:05" itemprop="dateCreated datePublished" datetime="2022-07-17T21:27:05+08:00">2022-07-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/07/17/STM32%20IAP%E8%B7%B3%E8%BD%ACAPP%E6%97%B6%E6%AD%BB%E6%9C%BA/" class="post-meta-item leancloud_visitors" data-flag-title="STM32 IAP跳转APP时死机" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/07/17/STM32%20IAP%E8%B7%B3%E8%BD%ACAPP%E6%97%B6%E6%AD%BB%E6%9C%BA/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/07/17/STM32%20IAP%E8%B7%B3%E8%BD%ACAPP%E6%97%B6%E6%AD%BB%E6%9C%BA/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        使用STM32F4做IAP升级的时候，跳转到APP执行的时候失败。查阅了网上的资料：<a target="_blank" rel="noopener" href="https://blog.csdn.net/u010650845/article/details/125369023?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0-125369023-blog-107209289.pc_relevant_aa&amp;spm=1001.2101.3001.4242.1&amp;utm_relevant_index=3%E3%80%82">https://blog.csdn.net/u010650845/article/details/125369023?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0-125369023-blog-107209289.pc_relevant_aa&amp;spm=1001.2101.3001.4242.1&amp;utm_relevant_index=3。</a></p>
<p>​        有可能是：</p>
<p>(1)BootLoader使用的中断，跳转APP前未关闭，APP启动后中断异常，需要逐个将中断关闭</p>
<p>(2)BootLoader使用了APP没有使用到的外设，跳转APP前未DeInit，APP启动后出现异常，需要逐个将使用到的资源DeInit</p>
<p>​        我的出问题的那个工程，是用cubemx自动生成初始化工程的，用的定时器1做基准，所以尝试对那个定时器做了些处理，竟然可以了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E8%B7%B3%E8%BD%AC%E5%89%8D%E5%BE%88%E9%87%8D%E8%A6%81%E7%9A%84%E4%B8%80%E5%8F%A5.png" style="zoom:67%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/07/17/%E5%AE%8F%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%90%8E%E5%8A%A0UL/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/07/17/%E5%AE%8F%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%90%8E%E5%8A%A0UL/" class="post-title-link" itemprop="url">宏定义变量后加UL</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-07-17 18:50:19" itemprop="dateCreated datePublished" datetime="2022-07-17T18:50:19+08:00">2022-07-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/07/17/%E5%AE%8F%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%90%8E%E5%8A%A0UL/" class="post-meta-item leancloud_visitors" data-flag-title="宏定义变量后加UL" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/07/17/%E5%AE%8F%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%90%8E%E5%8A%A0UL/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/07/17/%E5%AE%8F%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%90%8E%E5%8A%A0UL/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​         字面常量如123一般隐式定义为int型，这样两个int型的数据进行操作后有可能所得的结果超出int型，为了解决这个问题，我们可以用UL强制把int型的数据转换为unsigned long，一旦有一个数据强制转换后，就执行“整型提升”，这样就可以解决溢出的问题了。</p>
<p>​        在32位的设备上，int的范围是-2147483648～2147483647，unsigned int范围是0~4294967295</p>
<p>一年的 SECONDS = 60* 60* 24<em>365 = 31,536,000。但是一百年的秒数就是100</em>SECONDS = 3,153,600,000，已经超过了int的上限，溢出了。所以需要SECOND为unsigned long（这里隐式转换了），在运算的时候保证运算的结果是对的。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/07/10/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E5%90%8D%E7%9A%84%E5%90%AB%E4%B9%89/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/07/10/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E5%90%8D%E7%9A%84%E5%90%AB%E4%B9%89/" class="post-title-link" itemprop="url">二维数组名的含义</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-07-10 12:12:33" itemprop="dateCreated datePublished" datetime="2022-07-10T12:12:33+08:00">2022-07-10</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2022/07/10/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E5%90%8D%E7%9A%84%E5%90%AB%E4%B9%89/" class="post-meta-item leancloud_visitors" data-flag-title="二维数组名的含义" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/07/10/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E5%90%8D%E7%9A%84%E5%90%AB%E4%B9%89/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/07/10/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E5%90%8D%E7%9A%84%E5%90%AB%E4%B9%89/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        本文来源于网络，原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_43913261/article/details/110101783">https://blog.csdn.net/weixin_43913261/article/details/110101783</a></p>
<p>​        我们知道数组是在内存里占据一片连续的内存空间，由此可以看到 数组名a的值为数组 a的第一个元素的地址，且数组名a自身的地址也和a指向的地址相同，即 <strong>a=&amp;a=&amp;a[0</strong>]</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">**在此基础上，我们再来看二维数组**</span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">   <span class="keyword">int</span> a[<span class="number">3</span>][<span class="number">5</span>];</span><br><span class="line">   <span class="keyword">int</span> (*p)[<span class="number">5</span>];</span><br><span class="line">        p=a;</span><br><span class="line">   	<span class="built_in">printf</span>(<span class="string">&quot; a=%d\n&quot;</span>,a);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot; &amp;a[0][0]=%d\n&quot;</span>,&amp;a[<span class="number">0</span>][<span class="number">0</span>]);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot; &amp;a=%d\n&quot;</span>,&amp;a);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot; *a=%d\n&quot;</span>,*a);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot; *p=%d\n&quot;</span>,*p); </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>输出结果：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202207101845470.png" style="zoom:80%;">

<p>​        由运行结果可知，a=&amp;a=&amp;a[0][0]，这点和一维数组一样，二维数组名a存储的地址（数组第一个元素的地址），也是其本身在内存中的地址。</p>
<p>​        但和一维数组不同的是，二维数组名是一个二重指针，即指针的指针。故在本例中，二维数组a[3][5]的数组名a代表为指向含有5个元素的数组的指针，所以 (*p)[5]才能被a赋值，即<strong>p=a</strong>。</p>
<p>​        又因为编译器从数组a的基本地址&amp;a[0][0]开始，按行为所有元素分配连续的储存空间。也就说，第二行的第一个元素紧邻第一行的最后一个元素（这就是为什么在声明二维数组时，必须指定每行大小的原因，这样，编译器就可以确定正确的存储映射了）。故在二维数组中，可以用如下指针表达式来表示元素：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">*（*(a+i)+j）或 *（*（p+i）+j）</span><br></pre></td></tr></table></figure>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202207101857116.png"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/05/21/%E5%8D%9A%E5%AE%A2%E4%BD%BF%E7%94%A8%E7%9A%84%E5%9B%BE%E5%BA%8A%E8%BF%81%E7%A7%BB%E5%88%B0%E9%98%BF%E9%87%8C%E4%BA%91OSS/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2022/05/21/%E5%8D%9A%E5%AE%A2%E4%BD%BF%E7%94%A8%E7%9A%84%E5%9B%BE%E5%BA%8A%E8%BF%81%E7%A7%BB%E5%88%B0%E9%98%BF%E9%87%8C%E4%BA%91OSS/" class="post-title-link" itemprop="url">博客使用的图床迁移到阿里云OSS</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-05-21 09:39:26" itemprop="dateCreated datePublished" datetime="2022-05-21T09:39:26+08:00">2022-05-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" itemprop="url" rel="index"><span itemprop="name">博客搭建</span></a>
                </span>
            </span>

          
            <span id="/2022/05/21/%E5%8D%9A%E5%AE%A2%E4%BD%BF%E7%94%A8%E7%9A%84%E5%9B%BE%E5%BA%8A%E8%BF%81%E7%A7%BB%E5%88%B0%E9%98%BF%E9%87%8C%E4%BA%91OSS/" class="post-meta-item leancloud_visitors" data-flag-title="博客使用的图床迁移到阿里云OSS" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/05/21/%E5%8D%9A%E5%AE%A2%E4%BD%BF%E7%94%A8%E7%9A%84%E5%9B%BE%E5%BA%8A%E8%BF%81%E7%A7%BB%E5%88%B0%E9%98%BF%E9%87%8C%E4%BA%91OSS/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/05/21/%E5%8D%9A%E5%AE%A2%E4%BD%BF%E7%94%A8%E7%9A%84%E5%9B%BE%E5%BA%8A%E8%BF%81%E7%A7%BB%E5%88%B0%E9%98%BF%E9%87%8C%E4%BA%91OSS/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        之前在gitee仓库中搭建的图床，发现不好用了，毕竟是免费的白嫖不好，所以准备迁移到阿里云OSS中。</p>
<h3 id="1-配置阿里云OSS"><a href="#1-配置阿里云OSS" class="headerlink" title="1.配置阿里云OSS"></a>1.配置阿里云OSS</h3><h4 id="1-1-注册-开通对象储存"><a href="#1-1-注册-开通对象储存" class="headerlink" title="1.1 注册,开通对象储存"></a>1.1 注册,开通对象储存</h4><p>​        到官网<a target="_blank" rel="noopener" href="https://www.aliyun.com/product/oss%EF%BC%8C%E6%B3%A8%E5%86%8C%E8%B4%A6%E6%88%B7%E5%B9%B6%E5%AE%9E%E5%90%8D%E5%90%8E%EF%BC%8C%E8%BF%9B%E5%85%A5%E4%BD%A0%E7%9A%84%E6%8E%A7%E5%88%B6%E5%8F%B0%E3%80%82">https://www.aliyun.com/product/oss，注册账户并实名后，进入你的控制台。</a></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212146783.png" style="zoom:67%;">

<p>选择对象储存并开通。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212149240.png"></p>
<h4 id="1-2-创建bucket"><a href="#1-2-创建bucket" class="headerlink" title="1.2 创建bucket"></a>1.2 创建bucket</h4><p>​    在左侧选择概览，然后在右侧创建一个新的bucket。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212152317.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212157505.png" style="zoom:80%;">

<p>创建完成后，点击确定就可以了。</p>
<h4 id="1-3-找到地域节点"><a href="#1-3-找到地域节点" class="headerlink" title="1.3 找到地域节点"></a>1.3 找到地域节点</h4><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212204236.png"></p>
<p>只需要复制oss-cn-shanghai即可，不需要后面的.aliyuncs.com，后面会用到这个。</p>
<h4 id="1-4-找到key"><a href="#1-4-找到key" class="headerlink" title="1.4 找到key"></a>1.4 找到key</h4><p>​        来到右上角，鼠标放在你的头像上，在弹出的框里选择AccessKey管理。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212211572.png" style="zoom:70%;">

<p>​        在弹出的选项框里，选择“继续使用”</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212213255.png" style="zoom:70%;">

<p>​        进入后，创建一个AccessKey，</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212215615.png" style="zoom:80%;">

<p>​        在弹出的界面里，记住你的accessKeyId和accessKeySecret。</p>
<h4 id="1-5-给阿里云账户充值"><a href="#1-5-给阿里云账户充值" class="headerlink" title="1.5 给阿里云账户充值"></a>1.5 给阿里云账户充值</h4><p>​        一共有两种计费方式。</p>
<p>​        第一种是按量收费，只需要开通OSS即可，然后就完事了（默认是第一种方式”按量收费“），就可以直接用OSS服务了，不需要付款什么的，按量收费，从我们的阿里云账户直接扣钱，边用边扣的模式。这种访问量不大的话也花不了多少钱<br>​        还有一种是”买套餐包月包年“，需要我们到页面付款一次结清，有活动的时候经常几块钱一年40G空间。<br>​        如果只用来放博客得图片得话，按量计费更好，一般不会耗费多少钱，有的时候还会抹零。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212220303.png"></p>
<h3 id="2-配置picgo"><a href="#2-配置picgo" class="headerlink" title="2.配置picgo"></a>2.配置picgo</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212228097.png" style="zoom:70%;">

<h3 id="3-配置typora"><a href="#3-配置typora" class="headerlink" title="3.配置typora"></a>3.配置typora</h3><p>​        进入typora主界面，点击左上角的“文件-偏好设置”</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212241625.png"></p>
<p>​    第二个对网络位置的图片应用上述规则可以不勾，避免已经上传到图床的图片重复上传。</p>
<p>​    设置完毕后，我们点击验证图片上传选项，如果出错，下载高版本的PicGo就可以解决。</p>
<h3 id="4-图片上传到阿里云"><a href="#4-图片上传到阿里云" class="headerlink" title="4.图片上传到阿里云"></a>4.图片上传到阿里云</h3><p>​        将gitee仓库里的图片都上传到阿里云上面。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212252486.png"></p>
<h3 id="5-博客中原来图片链接修改"><a href="#5-博客中原来图片链接修改" class="headerlink" title="5.博客中原来图片链接修改"></a>5.博客中原来图片链接修改</h3><p>​        需要把原来博客中图片的gitee链接地址换成新的，这里不用网上复杂的写脚本的方式，直接使用vscode打开并且替换的方式就可以了，非常方便。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202205212255333.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/14/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/14/">14</a><span class="page-number current">15</span><a class="page-number" href="/page/16/">16</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/16/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
